package entityManager

import (
	"gitee.com/fierce_wolf/go-fox-edge-common/commEntity"
	"gitee.com/fierce_wolf/go-fox-edge-common/commEntityManager"
	"gitee.com/fierce_wolf/go-fox-edge-common/commRedisService"
	"gitee.com/fierce_wolf/go-fox-edge-common/commSql"
	"gitee.com/fierce_wolf/go-fox-edge-common/commUtil/Map"
)

func Instance(others map[string]interface{}) {
	producer := commRedisService.IRedisManager.GetRedisProducer()
	consumer := commRedisService.IRedisManager.GetRedisConsumer()
	writer := commRedisService.IRedisManager.GetRedisWriter()

	consumer[commEntity.Type.ConfigEntity.Type()] = nil
	consumer[commEntity.Type.ChannelEntity.Type()] = nil
	Map.Append(consumer, others)

	writer[commEntity.Type.ChannelStatusEntity.Type()] = nil

	// 初始化数据库的字典
	for key := range consumer {
		commSql.Register(key)
	}
	for key := range producer {
		commSql.Register(key)
	}
	for key := range writer {
		commSql.Register(key)
	}
}

func InitLoadEntity() {
	commEntityManager.InitLoadEntity()
}

// Scheduler 线程函数
func Scheduler() {
	commEntityManager.Scheduler()
}
